#include <command_pattern.h>
#include <iostream>

void Stock::buy()
{
    cout << "Stock [ Name: " << this->name << ", Quantity: " << this->quantity << " ] bought" << endl;
}

void Stock::sell()
{
    cout << "Stock [ Name: " << this->name << ", Quantity: " << this->quantity << " ] sold" << endl;
}

BuyStock::BuyStock(Stock* abcStock)
{
    this->abcStock = abcStock;
}

BuyStock::~BuyStock()
{
    delete this->abcStock;
}

void BuyStock::execute()
{
    this->abcStock->buy();
}

SellStock::SellStock(Stock* abcStock)
{
    this->abcStock = abcStock;
}

SellStock::~SellStock()
{
    delete this->abcStock;
}

void SellStock::execute()
{
    this->abcStock->sell();
}

void Broker::takeOrder(Order *order)
{
    this->orderList.push_back(order);
}

void Broker::placeOrders()
{
    list<Order*>::iterator it = this->orderList.begin();
    for(; it != this->orderList.end(); it++)
    {
        (*it)->execute();
    }
    this->orderList.clear();
}
